Skip to content

Respect Lua mode in CLI compilation - #1227

Merged
Frotty merged 4 commits into
masterfrom
agent/lua-mode-cli-output
Aug 14, 2026
Merged

Respect Lua mode in CLI compilation#1227
Frotty merged 4 commits into
masterfrom
agent/lua-mode-cli-output

Conversation

@Frotty

@Frotty Frotty commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

  • route the CLI fallback through the Lua backend when -lua is present
  • prevent explicit .j output paths from producing Jass artifacts in Lua mode
  • insert war3map.lua for Lua CLI map compilation and remove stale Jass scripts
  • add a regression test covering a requested output.j path

Root cause

CompilationProcess unconditionally transformed and printed Jass. This affected CLI commands used by Grill when project run arguments selected Lua, even though the language-server map pipeline was already Lua-aware.

Validation

  • staged diff passed git diff --cached --check
  • focused Gradle test was attempted but compilation was blocked by pre-existing conflict markers in unrelated SyntacticSugar.java changes in the working tree

@Frotty
Frotty force-pushed the agent/lua-mode-cli-output branch from 54b0b6e to 138e0f6 Compare August 14, 2026 13:30
@Frotty
Frotty marked this pull request as ready for review August 14, 2026 13:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 138e0f667d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

mpqEditor.deleteFile("war3map.j");
byte[] war3map = compiledScript.toString().getBytes(Charsets.UTF_8);
mpqEditor.insertFile("war3map.j", war3map);
String mapScriptName = compileArgs.isLua() ? "war3map.lua" : "war3map.j";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the map metadata when switching to Lua

When -lua is selected for an existing Jass map, this changes the injected filename but leaves war3map.w3i marked as Jass and potentially in an older W3I format. The centralized flow explicitly calls w3I.setScriptLang(W3I.ScriptLang.LUA) and upgrades the format in ProjectConfigBuilder.apply; without that, the client can look for a Jass script after this branch has deleted it. Route this map update through the shared pipeline so the W3I is rewritten and injected alongside war3map.lua.

AGENTS.md reference: AGENTS.md:L147-L153

Useful? React with 👍 / 👎.

Comment on lines +185 to +187
if (compileArgs.isLua()) {
mpqEditor.deleteFile("war3map.j");
mpqEditor.deleteFile("scripts\\war3map.j");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Delete the previous Lua script from both MPQ locations

When the input map contains its Lua entry point at scripts\war3map.lua, the Lua branch deletes only the Jass entries and then inserts another Lua script at the archive root. The shared injector deliberately removes all four root/subdirectory variants before insertion; leaving the alternate Lua entry produces competing scripts and can cause the stale script to be loaded instead of the newly compiled one.

AGENTS.md reference: AGENTS.md:L162-L164

Useful? React with 👍 / 👎.

mpqEditor.deleteFile("scripts\\war3map.lua");
}
byte[] mapScript = compiledScript.toString().getBytes(Charsets.UTF_8);
mpqEditor.insertFile(mapScriptName, mapScript);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include configured external Lua chunks in CLI-built maps

For projects with files under the workspace lua/ directory, this direct insertion writes only the translator output. The centralized Lua map flow invokes injectExternalLuaFiles, prepending pre_*.lua files and appending the remaining chunks; skipping that composition leaves custom Lua definitions and initializers out of CLI-built maps, causing runtime failures for projects that rely on them. Use the shared map pipeline rather than inserting the raw script here.

AGENTS.md reference: AGENTS.md:L162-L164

Useful? React with 👍 / 👎.

Frotty commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0b3b834a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +165 to +166
if (runArgs.isLua() && outputPath.toLowerCase(Locale.ROOT).endsWith(".j")) {
outputPath = outputPath.substring(0, outputPath.length() - 2) + ".lua";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove stale Jass output when redirecting Lua builds

When a user previously compiled Jass to -out output.j and then reruns the same command with -lua, this branch writes output.lua but leaves the old output.j untouched. Downstream tools that still inspect the explicitly requested path can therefore consume obsolete Jass, and the new guarantee that Lua mode does not leave a .j artifact only holds in a clean directory. Delete the superseded file or write the Lua output to the exact requested path.

Useful? React with 👍 / 👎.

Frotty commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Object result = cliBuildMap.execute(modelManager);

P2 Badge Preserve explicit output files in routed map compilations

For a workspace invocation such as -lua -out generated.lua -workspaceroot <root> <map.w3x> without -build, this branch now returns through CliBuildMap; that pipeline writes only its hard-coded _build/02_compiled.lua artifact and never consumes RunArgs.getOutFile(), so the requested output is not updated and stale contents can remain. The fresh evidence beyond the prior stale-output report is that this new routing bypasses the corrected writeMapscript implementation entirely; have the shared pipeline materialize the explicitly requested script output.

AGENTS.md reference: AGENTS.md:L162-L164

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (projectConfig == null) {
throw new RuntimeException(FILE_NAME + " file doesn't exist or is invalid.");
}
CliBuildMap cliBuildMap = new CliBuildMap(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve requested tests in workspace map builds

When the CLI is invoked with -runtests -workspaceroot <root> <map.w3x> without -build, this broadened routing now constructs CliBuildMap and returns after its pipeline finishes. MapRequest.compileMap never checks isRunTests() or calls RunTests, whereas the replaced CompilationProcess.doCompilation path did, so failing tests are silently skipped and the command reports a successful build. Execute requested tests from the shared map pipeline before reporting success.

AGENTS.md reference: AGENTS.md:L162-L164

Useful? React with 👍 / 👎.

Frotty commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

de.peeeq.wurstio.languageserver.ModelManager modelManager =
new de.peeeq.wurstio.languageserver.ModelManagerImpl(root.toFile(), new de.peeeq.wurstio.languageserver.BufferManager());
modelManager.buildProject();

P1 Badge Preserve CLI library directories when building the model

When a workspace map build supplies -lib directly or through wurst_run.args, this new route builds the project with a plain ModelManagerImpl before the compiler receives the merged RunArgs. ModelManagerImpl.getCompiler() uses defaults plus only _build/dependencies, so imports from the requested library are reported as unresolved and CliBuildMap.execute() aborts on hasErrors(); the replaced CompilationProcess path honored runArgs.getAdditionalLibDirs(). Pass the CLI library directories into the model build or otherwise load them before checking model errors.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty
Frotty merged commit 73f0a98 into master Aug 14, 2026
6 checks passed
@Frotty
Frotty deleted the agent/lua-mode-cli-output branch August 14, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant